/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.yourorghere;

import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.glu.GLU;


/**
 *
 * @author henriquediomede
 */
public class Camera
{
    private void initCamera()
    {
        position[0] = 0;
        position[1] = 2;
        position[2] = 0;
    }
    
    public Camera()
    {
        directions = new float[3];
        look = new float[3];
        position = new float[3];
        initCamera();
        acc = 0;
        angle = 0;
    }
    
    public Camera(int x, int y, int z)
    {
        
    }
    
    public void placeCamera(GLAutoDrawable drawable)
    {
        GL gl = drawable.getGL();
        GLU glu = new GLU();
        gl.glMatrixMode(GL.GL_MODELVIEW);
        gl.glLoadIdentity();
        glu.gluLookAt(position[0] , position[1], position[2], look[0], look[1], look[2], 0, 1, 0);
        //glu.gluLookAt(0 , 2, 2, 0, 2, 0, 0, 1, 0);

    }
    
    public void update()
    {
        final int temp [] = Keyboard.getInput();
        
        if(temp[0] == 1)
            angle += 2;
        
        if(temp[1] == 1)
            angle -= 2;
        
        if(temp[2] == 1)
            acc += 1;
            
        if(temp[3] == 1)
            acc -=1;
        
        directions[0] = (float) (Math.cos(Math.toRadians(angle)));
        directions[1] = 0;
        directions[2] = (float) (Math.sin(Math.toRadians(angle)));
       
        position[0] += acc * directions[0];
        position[1] += acc * directions[1];
        position[2] += acc * directions[2];
        
        look[0] = position[0] + directions[0];
        look[1] = position[1] + directions[1];
        look[2] = position[2] + directions[2]; 
        
//        System.out.println(position[0]);
//        System.out.println(position[1]);
//        System.out.println(position[2]);
        acc = 0;
    }
    
  
    private int angle;
    private int acc;
    private float look[];
    private float position[];
    private float directions[];
}
